<template>
	<view class="content">
		<scroll-view scroll-y="true" class="main">
			<view class="orderleveltop">
				<image src="../../static/pages_order/bg.png" class="bg" mode=""></image>
				<u-navbar title="加钟" :fixed='false' :border='false' bgColor="rgbg(0,0,0,0)" leftIconColor='#fff'
					:autoBack="true" titleStyle="color:#fff;"></u-navbar>
				<view class="u-m-t-50 white u-font-bold u-font-30">当前服务项目：</view>
				<view class="levellist">
					<view class="levellist_item flex">
						<image class="project" :src="$oss(cate.image)" mode=""></image>
						<view class="levellist_item_middle flex">
							<text class="u-font-30">{{cate.name}}</text>
							<view class="flex">
								<view class="tips u-font-24">
									{{cate.intro}}
								</view>
							</view>
							<view class="price">
								<text class="u-font-24">¥</text>
								<text class="u-font-34 u-font-bold"> {{cate.price}}</text>
							</view>
						</view>
						<view class="levellist_item_right_top flex">
							<image src="/static/pages_order/time.png" mode=""></image>
							<text class="u-font-28">{{cate.costmin}}分钟</text>
						</view>
					</view>
				</view>
			</view>
			<view class="levellist u-m-tb-50">
				<view class="  u-font-bold u-font-30">可加钟以下项目：</view>
				<view class="levellist_item flex" v-for="item in list" @click="ids =item.id">
					<image class="project" :src="$oss(item.image)" mode=""></image>
					<view class="circleBox">
						<view class="select circle" v-if="ids!=item.id"></view>
						<image class="select" v-else src="/static/selected.png" mode="widthFix"></image>
					</view>
					<view class="levellist_item_middle flex">
						<text class="u-font-30">{{item.name}}</text>
						<view class="flex">
							<view class="tips u-font-24">
								{{item.intro}}
							</view>
						</view>
						<view class="price">
							<text class="u-font-24">¥</text>
							<text class="u-font-34 u-font-bold"> {{item.price}}</text>
						</view>
					</view>
					<view class="levellist_item_right_top flex">
						<image src="/static/pages_order/time.png" mode=""></image>
						<text class="u-font-28">{{item.costmin}}分钟</text>
					</view>
					<view class="numBox">
						<u-number-box v-model="item.num" integer button-size="30" color="#000" bgColor="#ffffff"
							iconStyle="color: #fff;border-radius: 50%;">
							<view slot="minus" class="minus">
								<u-icon name="minus" size="12" color="#FFFFFF"></u-icon>
							</view>
							<view slot="plus" class="plus">
								<u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
							</view>
						</u-number-box>
					</view>

				</view>
			</view>
			<u-empty mode="list" v-if="finish && list.length === 0" style="margin-top: 200rpx;" icon="/static/none.png">
					</u-empty>
		</scroll-view>
		<view class="bottom_btn">
			<view class="btn" @click="addpay">立即加钟</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cate: '',
				service_id: '',
				num: '',
				id: '',
				list: [],
				finish:false,
				ids: ''
			};
		},
		onLoad(option) {
			this.cate = JSON.parse(decodeURIComponent(option.cate))
			this.service_id = option.service_id
			this.num = option.num
			this.id = option.id
			this.getInfo()
		},
		methods: {
			
			addpay() {
				if(this.ids === '') return this.$toast('请选择加钟项目')
				let num,item;
				for(let i=0; i< this.list.length;i++){
					if(this.ids === this.list[i].id){
						num = this.list[i].num || 1
						item = this.list[i]
					}
				}
				let money = Number(item.price*num).toFixed(2)
				uni.navigateTo({
					url: '/pages_order/orderadd/payOrder?order_id=' + this.id + '&money=' + money + '&cate_id=' +
						item.id + '&num=' + num + '&name=' + item.name
				})
			},
			getInfo() {
				this.$api.post('/getskillinfo', {
					service_id: this.service_id,
					type:2
				}).then(res => {
					if (res.code == 1) {
						this.list = res.data.cateInfo
						if(res.data.cateInfo){
							this.finish = true
						}
					}
				}).catch((res) => {

				})
			}
		}
	}
</script>

<style lang="scss">
	.main ::v-deep .u-navbar__content {
		display: flex;
		flex-direction: row;
		align-items: center;
		height: 44px;
		background-color: rgba(1, 1, 1, 0) !important;
		position: relative;
		justify-content: center;
		color: #fff;
	}

	::v-deep .u-navbar__content__title[data-v-95dec1ae] {
		text-align: center;
		font-size: 16px;
		color: #fff;
	}

	.content {
		display: flex;
		flex-direction: column;
		height: 100vh;
	}
	.bottom_btn{
		width: 750rpx;
		height: 190rpx;
		background: #FFFFFF;
		box-shadow: inset 0rpx 1rpx 0rpx 0rpx #EBEBEB;
		overflow: hidden;
		.btn{
			width: 686rpx;
			height: 96rpx;
			background: $uni-primary;
			border-radius: 48rpx;
			margin: 20rpx auto 0;
			text-align: center;
			line-height: 96rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.main {
		flex: 1;
		overflow: hidden;
	}

	.minus,
	.plus {
		width: 44rpx;
		height: 44rpx;
		background-color: #00CE9B;
		color: #fff;
		border-radius: 50%;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
	}

	.numBox {
		position: absolute;
		right: 10rpx;
		bottom: 24rpx;
	}

	.orderleveltop {
		box-sizing: border-box;
		width: 100vw;
		height: 546rpx;

		.bg {
			width: 100%;
			height: 546rpx;
			position: absolute;
			left: 0;
			top: 0;
		}

		.levellist {
			position: relative;
			z-index: 10;
			box-sizing: border-box;
			.levellist_item {
				position: relative;
				margin-top: 50rpx;
				align-items: center;
				background-color: #fff;
				border-radius: 30rpx;
				width: 100%;
				box-sizing: border-box;
				.project {
					width: 195rpx;
					height: 160rpx;
					border-radius: 30rpx 0 30rpx 0;
					margin-right: 20rpx;
				}

				.levellist_item_middle {
					justify-content: space-between;
					flex-direction: column;
					height: 170rpx;

					.tips {
						border: 1rpx solid #8D93A5;
						padding: 5rpx 10rpx;
						border-radius: 20px;
						color: #8D93A5;

						&:nth-child(n+2) {
							margin-left: 10rpx;
						}
					}

					.price {
						color: #E91919;
					}
				}

				.levellist_item_right_top {
					position: absolute;
					right: 0;
					top: 20rpx;
					width: 143rpx;
					height: 53rpx;
					background: #EBFBF7;
					border-radius: 100rpx 0rpx 0rpx 100rpx;
					color: $uni-primary;
					text-align: center;
					align-items: center;
					justify-content: space-between;
					padding: 0 20rpx;

					image {
						width: 24rpx;
						height: 25rpx;
					}
				}

				.sjbtn {
					width: 150rpx;
					height: 56rpx;
					background: #00CE9B;
					border-radius: 28rpx;
					line-height: 56rpx;
					justify-content: center;
					margin-top: 100rpx;
					margin-left: 20rpx;
				}
			}
		}
	}

	.levellist {
		padding: 30rpx;

		.levellist_item {
			position: relative;
			margin-top: 50rpx;
			align-items: center;
			background-color: #fff;
			border-radius: 30rpx;
			padding: 30rpx 0rpx 30rpx 30rpx;
			.circleBox{
				position: absolute;
				left: 10rpx;
				top: 10rpx;
				width: 32rpx;
				height: 32rpx;
				.select{
					width: 32rpx;
					height: 32rpx;
				}
			}
			.project {
				width: 195rpx;
				height: 160rpx;
				border-radius: 30rpx 0 30rpx 0;
				margin-right: 20rpx;
			}

			.levellist_item_middle {
				justify-content: space-between;
				flex-direction: column;
				height: 170rpx;

				.tips {
					border: 1rpx solid #8D93A5;
					padding: 5rpx 10rpx;
					border-radius: 20px;
					color: #8D93A5;

					&:nth-child(n+2) {
						margin-left: 10rpx;
					}
				}

				.price {
					color: #E91919;
				}
			}

			.levellist_item_right_top {
				position: absolute;
				right: 0;
				top: 20rpx;
				width: 143rpx;
				height: 53rpx;
				background: #EBFBF7;
				border-radius: 100rpx 0rpx 0rpx 100rpx;
				color: $uni-primary;
				text-align: center;
				align-items: center;
				justify-content: space-between;
				padding: 0 20rpx;

				image {
					width: 24rpx;
					height: 25rpx;
				}
			}

			.sjbtn {
				width: 150rpx;
				height: 56rpx;
				background: #00CE9B;
				border-radius: 28rpx;
				line-height: 56rpx;
				justify-content: center;
				margin-top: 100rpx;
				margin-left: 20rpx;
			}
		}
	}
</style>